<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>公告列表</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<script type="text/javascript">
	function check(id){
		if(confirm('确定删除该公告？')) {
			location.href="${pageContext.request.contextPath }/notice/delete/"+id;
		}
	}
</script>
</head>
<body>
	<c:if test="${noticeList.size() == 0 }">
		此处还没有公告。
	</c:if>
	<c:if test="${noticeList.size() != 0 }">
	<div align="center">
		<div style="width: 100%; text-align: center;font-weight: bold;font-size: 20px; padding: 20px 0px 20px 0px;">公告列表</div>
			<table class="table table-hover" style="width: 80%;">
				<!--<caption>公告列表</caption>-->
				<tr>
					<th width=10%>&nbsp;#</th>
					<th width=50%>公告标题</th>
					<th width=20%>发表时间</th>
					<th width=10% style="text-align:center">查看</th>
					<th width=10% style="text-align:center">管理</th>
				</tr>
				<c:forEach items="${noticeList }" var="notice">
					<tr>
						<td>${notice.id }</td>
						<td>${notice.ntitle }</td>
						<td>${notice.ntime }</td>
						<td style="text-align:center"><a href="${pageContext.request.contextPath }/notice/selectANotice?id=${notice.id }" class="btn btn-primary">详情</a>
						<td style="text-align:center"><a href="javascript:check('${notice.id }')" class="btn btn-danger">删除</a>
					</tr>
				</c:forEach>
			</table>
		</div>
		<div align="center">
			<table class="table" style="width: 80%">
				<tr>
					<td>
						共<font style="font-weight: bold;">&nbsp;${totalData }&nbsp;</font>条公告&nbsp;&nbsp;共<font style="font-weight: bold;">&nbsp;${totalPage }&nbsp;</font>页
					</td>
				</tr>
				<tr>
					<td>
						<c:if test="${page == 1 }">
							<a href="#" style="pointer-events: none;" class="btn btn-default">&lt;</a>
						</c:if>
						<c:if test="${page != 1 }">
							<a href="${pageContext.request.contextPath }/notice/select/${page - 1 }" class="btn btn-default">&lt;</a>
						</c:if>
						<c:forEach items="${curPage }" var="i">
							<c:if test="${page == i }">
								<a href="#" target="center" style="pointer-events: none;" class="btn btn-primary">${i }</a>
							</c:if>
							<c:if test="${page != i}">
								<a href="${pageContext.request.contextPath }/notice/select/${i}" target="center" class="btn btn-default">${i }</a>
							</c:if>
						</c:forEach>
						<c:if test="${page == totalPage }">
							<a href="#" style="pointer-events: none;" class="btn btn-default">&gt;</a>
						</c:if>
						<c:if test="${page != totalPage }">
							<a href="${pageContext.request.contextPath }/notice/select/${page + 1 }" class="btn btn-default">&gt;</a>
						</c:if>
					</td>
				</tr>
			</table>
		</div>
	</c:if>
</body>
</html>